import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

import persist from "vuex-persist";

export default new Vuex.Store({
  state: {
    nc:'',
    pwd:'',
    mob:'',
    wishList:[]
  },
  mutations: {
    log(state,val){
      state.nc=val.nc
      state.pwd=val.pwd
      state.mob=val.mob
    },
    wish(state,val){
      state.wishList.push(val);
    },
    del(state,i){
      // console.log(i);
      state.wishList.forEach((item,index)=>{
        // console.log(item);
        if(item.id==i){
          state.wishList.splice(index,1)
        }
      })
    },
    remember(state,val){
      state.wishList.forEach((item,i)=>{
        if(i==val.i){
          item=val.item
        }
      })
    }
  },
  actions: {
  },
  modules: {
  },
  plugins: [
    new persist({
        storage: window.localStorage,
    }).plugin,
],
})
